home *** CD-ROM | disk | FTP | other *** search
/ Varios Español / Varios Español.iso / PMAKER65 / archive.z / REDIMENSIONAR GRUPO....SPT < prev    next >
Text File  |  1996-11-10  |  9KB  |  300 lines

  1. -- Resize Group...
  2. -- 1 Oct 96, vs
  3.  
  4. -- Este gui≤n redimensiona todos los elementos en un grupo
  5. -- incluyendo bloques de texto. Los tama±os y anchuras de fuentes 
  6. -- se ajustarßn a las nuevas dimensiones.
  7.  
  8.  
  9. getselectidlisttop >> N,...,...,...,...,typ,...
  10. if not(N,typ=1,14)
  11.     return unquote("Estado no vßlido")
  12. endif
  13.  
  14. // Pre-Step 1: Scan all textblocks in a group;
  15. // list 'em by IDs
  16. getselectidlisttop >> ...,idg,...
  17. getgrouplist idg >> N,grouplist
  18. groupidlist = 
  19. loop n=1,N
  20.     set grouplist >> id,...,...,...,typ,...,...,...,...,...,...,...,...,...,...,grouplist
  21.     if typ = 1
  22.         groupidlist = groupidlist,id
  23.     endif
  24. endloop
  25. storyid.dejavu =  //dont bother twice about the same story within the group
  26. deselect
  27.  
  28. // Pre-Step 2: Scan all the stories in the group:
  29. // If some story has a textblock outside the group - bail out
  30. getgrouplist idg >> N,grouplist
  31. loop n=1,N
  32.     set grouplist >> id,...,...,...,typ,...,...,...,...,...,...,...,...,...,...,grouplist
  33.     //message str(typ)
  34.     if typ = 1
  35.         selectid id
  36.         textedit
  37.         gettextcursor >> storyid,pos,...
  38.         if not ( storyid ? storyid.dejavu )
  39.             storyid.dejavu = storyid.dejavu , storyid
  40.             textcursor +story
  41.             repeat
  42.                 textcursor -char
  43.                 textcursor -textblock
  44.                 gettextlocation >> idtxt,...
  45.                 if not ( idtxt ? groupidlist )
  46.                     return unquote("Estado no vßlido")
  47.                 endif
  48.                 gettextcursor >> ...,pos,...
  49.             until pos=0    
  50.         endif
  51.     endif                
  52. endloop
  53. deselect
  54.  
  55. // Pre Step 3 : remember transformation of a textblocks
  56. selectid idg
  57. getgrouplist idg >> N,grouplist
  58. loop n=1,N
  59.     set grouplist >> id,...,...,...,typ,...,...,...,...,...,...,...,...,...,...,grouplist
  60.     if typ = 1
  61.         selectid id
  62.         gettransform >> rot[id],skew[id],...
  63.         textedit
  64.         gettextcursor >> ...,begin[id],...
  65.         textcursor +textblock
  66.         gettextcursor >>...,end[id],...
  67.         textselect +char
  68.         textenter ""(0x(13))
  69.         deselect
  70.     endif                
  71. endloop
  72. deselect
  73. selectid idg
  74.  
  75. // Now, as the task looks doable, accept and handle user's input.
  76. getobjectloc center => xc,yc
  77.  
  78. getplatform => platform
  79. if platform = WINDOWS
  80. dialogbegin -65,-80,65,30,"Escalar grupo"
  81.   pushbutton 88,30,122,44,"OK"
  82.   pushbutton 88,51,122,65,"Cancelar"
  83.   edit 28,7,45,17,"100"
  84.   static 48,8,54,18,"%"
  85.   static 3,8,24,18,"Altura"
  86.   edit 97,7,114,17,"100"
  87.   static 116,8,122,18,"%"
  88.   static 65,8,95,18,"Anchura"
  89.   static 5,22,62,32,"Punto de anclaje:"
  90.   radiobutton 10,32,82,44,"Superior izquierdo.",1
  91.   radiobutton 10,44,82,56,"Superior derecho."
  92.   radiobutton 10,56,88,68,"Inferior derecho."
  93.   radiobutton 10,68,81,80,"Inferior izquierdo."
  94.   radiobutton 10,82,44,94,"Propio: "
  95.   static 44,82,56,94,"x "
  96.   edit 58,82,86,91,""(xc)
  97.   static 44,94,56,104,"y"
  98.   edit 58,94,86,102,""(yc)
  99. dialogend =>  ButtonHit,...,...,kh,...,...,kw,...,...,...,lt,rt,rb,lb,cust,...,xc,...,yc,...
  100. else
  101. dialogbegin -165,-200,165,75,"Escalar grupo"
  102.   pushbutton 232,82,298,108,"OK"
  103.   pushbutton 230,130,300,160,"Cancelar"
  104.   static 25,55,130,80,"Punto de anclaje:"
  105.   radiobutton 25,80,205,110,"Superior izquierdo.",1
  106.   radiobutton 25,110,205,140,"Superior derecho."
  107.   radiobutton 25,140,220,170,"Inferior derecho."
  108.   radiobutton 25,170,205,200,"Inferior izquierdo."
  109.   radiobutton 25,205,110,240,"Propio: "
  110.   static 110,205,140,240,"x "
  111.   edit 145,205,215,227,""(xc)
  112.   static 110,235,140,265,"y"
  113.   edit 145,235,215,257,""(yc)
  114.   edit 70,22,110,42,"100"
  115.   static 120,22,135,50,"%"
  116.   static 8,22,60,50,"Height"
  117.   edit 240,22,275,42,"100"
  118.   static 285,22,305,50,"%"
  119.   static 175,22,235,50,"Anchura"
  120. dialogend =>  ButtonHit,...,...,...,lt,rt,rb,lb,cust,...,xc,...,yc,kh,...,...,kw,...,...
  121. endif
  122.  
  123. if (ButtonHit="Cancelar")+empty(ButtonHit)
  124.   return
  125. endif
  126.  
  127. set ~""(kh)/100=> kh
  128. set ~""(kw)/100=> kw
  129. set ~""(xc)=>xc
  130. set ~""(yc)=>yc
  131.  
  132. // Pre-Step 3: Secure all textblock in a group against loosing 'em when resizing
  133. // or changing text attributes. Put more text in each story
  134. --kw = 1.5
  135. --kh = 0.8
  136. k = max(1,kw)*max(1,kh)-1
  137. k = trunc(k)+1
  138. getgrouplist idg >> N,grouplist
  139. loop n=1,N
  140.     set grouplist >> id,...,...,...,typ,...,...,...,...,...,...,...,...,...,...,grouplist
  141.     if typ=1
  142.         selectid id
  143.         textedit
  144.         gettextcursor >> ...,pos,...
  145.         if pos=0
  146.             selectall
  147.             copy
  148.             textcursor +story            
  149.             gettextcursor >> ...,begin.tmp[id],...
  150.             loop i = 1,k
  151.                 paste
  152.             endloop
  153.             gettextcursor >> ...,end.tmp[id],...
  154.         endif
  155.     endif
  156. endloop
  157.  
  158. // now resize group
  159. selectid idg
  160. switch lt,rt,rb,lb
  161.     caseof 1,0,0,0
  162.         resizepct rightbottom,kw*100,kh*100
  163.         break
  164.     caseof 0,1,0,0
  165.         resizepct leftbottom,kw*100,kh*100
  166.         break
  167.     caseof 0,0,1,0
  168.         resizepct lefttop,kw*100,kh*100
  169.         break
  170.     caseof 0,0,0,1
  171.         resizepct righttop,kw*100,kh*100
  172.         break
  173.     default
  174.         getobjectloc lefttop >> xLT,yLT
  175.         getobjectloc rightbottom >> xRB,yRB
  176.         set xc+kw*(xLT-xc) => xLT
  177.         set yc+kh*(yLT-yc) => yLT
  178.         set xc+kw*(xRB-xc) => xRB
  179.         set yc+kh*(yRB-yc) => yRB
  180.         resize lefttop,xLT,yLT
  181.         resize rightbottom,xRB,yRB
  182. endswitch
  183.  
  184. // Post Step 1: adjust text attributes
  185. getgrouplist idg >> N,grouplist
  186. loop n=1,N
  187.     //breakpoint
  188.     set grouplist >> id,...,...,...,typ,...,...,...,...,...,...,...,...,...,...,grouplist
  189.     if typ=1
  190.         // calculate virtual koefficients of text attributes
  191.         m11 = kw*cos(rot[id])
  192.         m21 = -kh*sin(rot[id])
  193.         m12 = kw*(sin(rot[id]) - cos(rot[id])*sin(skew[id])/cos(skew[id]) )
  194.         m22 = kh*(sin(rot[id])*sin(skew[id])/cos(skew[id])+cos(rot[id]) )
  195.         kx = sqrt ( m11*m11+m21*m21)
  196.         ky = abs(m11*m22-m12*m21)/kx
  197.         
  198.         selectid id
  199.         textedit
  200.         gettextcursor >> ...,pos,...
  201.         if 1
  202.             settextcursor -2,begin[id],end[id]
  203.             gettextcursor >> ...,begin,end
  204.             settextcursor -2,begin,begin
  205.             set begin => tc
  206.             while tc<end
  207.               textselect +para
  208.               gettextcursor => ...,tc,tc1
  209.               gethyphenation => cState,nHyphenLimit,xZone
  210.               hyphenation cState,nHyphenLimit,min(2,kx*xZone)
  211.               getindents => xLeftIndent,xFirstIndent,xRightIndent
  212.               indents min(kx*xLeftIndent,21),(abs(kx*xFirstIndent+21)-abs(kx*xFirstIndent-21))/2,min(21,kx*xRightIndent)
  213.               getleading => leading
  214.               if leading>-1
  215.                 leading min(ky*leading,1300)
  216.                 endif
  217.                 getparaspace => ySpaceBefore,ySpaceAfter
  218.               paraspace min(ky*ySpaceBefore,22),min(ky*ySpaceAfter)
  219.               getruleabove => bRuleOn,cLineStyle,sLineColor,cLineWidth,xLeftIndent,xRightIndent,dWeight,bOpaque
  220.               if bRuleOn
  221.                 ruleabove  bRuleOn,cLineStyle*not(cLineStyle=31),sLineColor,ky*cLineWidth,min(kx*xLeftIndent,21),min(kx*xRightIndent,21),trunc(0.5+k*dWeight*10)/10,bOpaque
  222.               endif
  223.               getrulebelow => bRuleOn,cLineStyle,sLineColor,cLineWidth,xLeftIndent,xRightIndent,dWeight,bOpaque
  224.               if bRuleOn
  225.                 rulebelow  bRuleOn,cLineStyle*not(cLineStyle=31),sLineColor,ky*cLineWidth,min(kx*xLeftIndent,21),min(kx*xRightIndent,21),trunc(0.5+k*dWeight*10)/10,bOpaque
  226.               endif
  227.               getruleoptions => yTopOffset,yBottomOffset,bAlighnToGrid,dGridSize
  228.               if yTopOffset>-1
  229.                 set min(ky*yTopOffset,22.75) => yTopOffset
  230.               endif
  231.               if yBottomOffset>-1
  232.                 set min(ky*yBottomOffset,22.75) => yBottomOffset
  233.               endif
  234.               ruleoptions yTopOffset,yBottomOffset,bAlighnToGrid,min(ky*dGridSize,1300)
  235.               getsize => size
  236.               if size >-2
  237.                 size max(4,min(ky*size,650))
  238.               endif
  239.               getwidth => width
  240.               if width>0
  241.                 set width*kx/ky => width
  242.                 width = min(width,250)
  243.                 width = max(width,5)
  244.                 setwidth width
  245.               endif
  246.               if (size=-2)+(leading=-2)+(width=-2)
  247.                 textselect -para
  248.                 set tc => tr
  249.                 while tr<tc1
  250.                   gettextrun 1 => ...,...,tr,...
  251.                   textselect +char,tr-tc
  252.                   getleading => leading
  253.                   if leading > -1
  254.                     leading min(ky*leading,1300)
  255.                   endif
  256.                    getsize => size
  257.                   size max(4,min(ky*size,650))
  258.                   getwidth => width
  259.                   set width*kx/ky => width
  260.                   width = min(width,250)
  261.                   width = max(width,5)
  262.                   setwidth width
  263.                   textselect -char,tr-tc
  264.                   textcursor +char,tr-tc
  265.                   set tr=> tc
  266.                 endwhile tr<tc1
  267.               endif  (size=-2)+(leading=-2)
  268.               gettextcursor => ...,a,b
  269.               if a<b
  270.                 textselect -para
  271.                 textcursor +para
  272.               endif
  273.               gettextcursor => ...,tc,tc1
  274.             endwhile
  275.         endif
  276.     endif
  277. endloop
  278. deselect
  279.  
  280. // Post Step 2: remove extra text from stories
  281. getgrouplist idg >> N,grouplist
  282. loop n=1,N
  283.     set grouplist >> id,...,...,...,typ,...,...,...,...,...,...,...,...,...,...,grouplist
  284.     if typ=1
  285.         selectid id
  286.         textedit
  287.         gettextcursor >> ...,pos,...
  288.         if pos=0
  289.             settextcursor -2,begin.tmp[id],end.tmp[id]        
  290.             clear
  291.         endif
  292.         deselect
  293.     endif
  294. endloop
  295.  
  296. selectid idg
  297.  
  298. return
  299.  
  300.